package com.zhongchaowuye.controller;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.Page;
import com.zhongchaowuye.pojo.A_ZD;
import com.zhongchaowuye.pojo.B_HT;
import com.zhongchaowuye.pojo.B_HT_M;
import com.zhongchaowuye.pojo.B_ShChDY;
import com.zhongchaowuye.pojo.B_TZh;
import com.zhongchaowuye.service.A_ZDService;
import com.zhongchaowuye.service.B_HT_MService;
import com.zhongchaowuye.service.B_ShChDYService;
import com.zhongchaowuye.service.B_TZhService;
import com.zhongchaowuye.utils.Tools;

@Controller
@RequestMapping("/c_Tjfx")
public class C_TjfxController {

	//以下内容是基于台账的项目每日成本汇总统计报表
	@Resource
	private B_TZhService b_TZhService;
	private double meiriheji=0; //用于（项目）每日成本统计报表，计算每行求和的全局变量
	
	@RequestMapping(value ="/getHzxx_meiri_leibie",method = RequestMethod.POST)
	@ResponseBody
	//（台账统计分析：按月份、按项目名称、按工作日）按月统计，每日按类别进行汇总统计
	public Map<String,Object> getHzxx_meiri_leibie(HttpServletRequest request,B_TZh b_TZh,Integer tz_gongzuori){
		Map<String,Object> reMap=new HashMap<>(); //定义返回值
		List<Map<String,Object>> pageList = new ArrayList<>(); //返回值中的页面集合项
		try {
			String start_time=b_TZh.getStart_time().substring(0,10); //"2024-11-01";
			String end_time=Tools.lastDayOfMonth(start_time);
			b_TZh.setStart_time(start_time+" 00:00:00");
			b_TZh.setEnd_time(end_time);
			List<Map<String,Object>> rList=b_TZhService.getHzxx_meiri_leibie(b_TZh); 
			//System.out.println(rList);//这种list方式的查询如果没有结果的话，会是[null]的方式返回
			
			//一：构造外循环（以11月为例，从1号循环到30号）
			int daysInMonth=Tools.daysInMonth(start_time);
			String yyyy=start_time.substring(0,4);
			String MM=start_time.substring(5,7);
			for(int i=1;i<=daysInMonth;i++){
				meiriheji=0; //按日期累计求和（外循环每次开始时都需要初始化一下，相当于一行一个合计数据）
				Map<String,Object> rowMap=new HashMap<>(); //行map（每一天是一行）
				String riqi="";
				if(i<=9){
					riqi=yyyy+"-"+MM+"-0"+i;
				}else{
					riqi=yyyy+"-"+MM+"-"+i;
				}
				String xingqi=Tools.dayOfWeek(riqi);
				if(rList.size()==0){
					System.out.println("需要赋一行空值，此时外循环日期=="+riqi);
					rowMap=setNull_row(riqi,xingqi); //每天生成一条空数据
					pageList.add(rowMap);
					if(i==daysInMonth){ //如果是当月最后一天
						Map<String,Object> rowMap_d2=setNull_row("本月合计",null); //倒数第二行（合计行）
						pageList.add(rowMap_d2);
						Map<String,Object> rowMap_d1=setNull_row("供餐日平均",tz_gongzuori.intValue()+"天"); //倒数第一行（日平均行）
						pageList.add(rowMap_d1);
						
						reMap.put("rows", pageList);
						reMap.put("status", "success");
						reMap.put("message", "OK");
						return reMap; //无数据的情况下，并执行完按月循环，生成当月天数的空数据后直接返回
					}
				}else{
					//1：先生成一条空数据
					rowMap=setNull_row(riqi,xingqi); //每天生成一条空数据
					int j=0;
					for(Map m:rList){ //柳林11月数据有197条统计记录
						j++;
						System.out.println("第"+j+"条数据库记录");
						String rq=(String)m.get("riqi");
						if(rq.equals(riqi)){
							//System.out.println("外循环i=="+i);
							//System.out.println("内循环比对相等的日期是=="+rq);
							//2：如果日期比对正确，则将数据填充到前面1：生成的空数据中
							setValue_row(rowMap,m);
						}
						//3：循环到最后一行，加入到集合
						if(j==rList.size()){
							pageList.add(rowMap);
						}
						//System.out.println("****=="+j);
					} //内for循环结束
				}
			} //外循环结束
			
			//二：处理该月每天数据集合pageList，补充最后两行（一行是按列合计，一行是按工作日平均合计）
			double shucai=0;double liangshi=0;double zaliang=0;double mianshi=0;double danlei=0;double fushi=0;
			double banchengpin=0;double tiaoliao=0;double ganhuo=0;double shiyongyou=0;double qinlei=0;double chulei=0;
			double shuichan=0;double yinliao=0;double shuiguo=0;double gaodian=0;double dizhi=0;double tianjiaji=0;
			double qita=0;double wuyeyongpin=0;double jihuawai=0;double total_meiriheji=0;
			//1：先算每列的合计
			for(int i=0;i<pageList.size();i++){
				Map<String,Object> m=pageList.get(i);
				shucai+=m.get("shucai")==null ? 0 : ((BigDecimal)m.get("shucai")).doubleValue();
				liangshi+=m.get("liangshi")==null ? 0 : ((BigDecimal)m.get("liangshi")).doubleValue();
				zaliang+=m.get("zaliang")==null ? 0 : ((BigDecimal)m.get("zaliang")).doubleValue();
				mianshi+=m.get("mianshi")==null ? 0 : ((BigDecimal)m.get("mianshi")).doubleValue();
				danlei+=m.get("danlei")==null ? 0 : ((BigDecimal)m.get("danlei")).doubleValue();
				fushi+=m.get("fushi")==null ? 0 : ((BigDecimal)m.get("fushi")).doubleValue();
				banchengpin+=m.get("banchengpin")==null ? 0 : ((BigDecimal)m.get("banchengpin")).doubleValue();
				tiaoliao+=m.get("tiaoliao")==null ? 0 : ((BigDecimal)m.get("tiaoliao")).doubleValue();
				ganhuo+=m.get("ganhuo")==null ? 0 : ((BigDecimal)m.get("ganhuo")).doubleValue();
				shiyongyou+=m.get("shiyongyou")==null ? 0 : ((BigDecimal)m.get("shiyongyou")).doubleValue();
				qinlei+=m.get("qinlei")==null ? 0 : ((BigDecimal)m.get("qinlei")).doubleValue();
				chulei+=m.get("chulei")==null ? 0 : ((BigDecimal)m.get("chulei")).doubleValue();
				shuichan+=m.get("shuichan")==null ? 0 : ((BigDecimal)m.get("shuichan")).doubleValue();
				yinliao+=m.get("yinliao")==null ? 0 : ((BigDecimal)m.get("yinliao")).doubleValue();
				shuiguo+=m.get("shuiguo")==null ? 0 : ((BigDecimal)m.get("shuiguo")).doubleValue();
				gaodian+=m.get("gaodian")==null ? 0 : ((BigDecimal)m.get("gaodian")).doubleValue();
				dizhi+=m.get("dizhi")==null ? 0 : ((BigDecimal)m.get("dizhi")).doubleValue();
				tianjiaji+=m.get("tianjiaji")==null ? 0 : ((BigDecimal)m.get("tianjiaji")).doubleValue();
				qita+=m.get("qita")==null ? 0 : ((BigDecimal)m.get("qita")).doubleValue();
				wuyeyongpin+=m.get("wuyeyongpin")==null ? 0 : ((BigDecimal)m.get("wuyeyongpin")).doubleValue();
				jihuawai+=m.get("jihuawai")==null ? 0 : ((BigDecimal)m.get("jihuawai")).doubleValue();
				total_meiriheji+=m.get("meiriheji")==null ? 0 : ((BigDecimal)m.get("meiriheji")).doubleValue();
			}
			//2：再生成最后两行
			int gzr=tz_gongzuori.intValue();
			Map<String,Object> r_d2=setNull_row("本月合计",null); //倒数第二行（合计行）
			Map<String,Object> r_d1=setNull_row("供餐日平均",null); //倒数第一行（日平均行）
			r_d2.put("shucai",BigDecimal.valueOf(Tools.round(shucai)));
			r_d2.put("liangshi",BigDecimal.valueOf(Tools.round(liangshi)));
			r_d2.put("zaliang",BigDecimal.valueOf(Tools.round(zaliang)));
			r_d2.put("mianshi",BigDecimal.valueOf(Tools.round(mianshi)));
			r_d2.put("danlei",BigDecimal.valueOf(Tools.round(danlei)));
			r_d2.put("fushi",BigDecimal.valueOf(Tools.round(fushi)));
			r_d2.put("banchengpin",BigDecimal.valueOf(Tools.round(banchengpin)));
			r_d2.put("tiaoliao",BigDecimal.valueOf(Tools.round(tiaoliao)));
			r_d2.put("ganhuo",BigDecimal.valueOf(Tools.round(ganhuo)));
			r_d2.put("shiyongyou",BigDecimal.valueOf(Tools.round(shiyongyou)));
			r_d2.put("qinlei",BigDecimal.valueOf(Tools.round(qinlei)));
			r_d2.put("chulei",BigDecimal.valueOf(Tools.round(chulei)));
			r_d2.put("shuichan",BigDecimal.valueOf(Tools.round(shuichan)));
			r_d2.put("yinliao",BigDecimal.valueOf(Tools.round(yinliao)));
			r_d2.put("shuiguo",BigDecimal.valueOf(Tools.round(shuiguo)));
			r_d2.put("gaodian",BigDecimal.valueOf(Tools.round(gaodian)));
			r_d2.put("dizhi",BigDecimal.valueOf(Tools.round(dizhi)));
			r_d2.put("tianjiaji",BigDecimal.valueOf(Tools.round(tianjiaji)));
			r_d2.put("qita",BigDecimal.valueOf(Tools.round(qita)));
			r_d2.put("wuyeyongpin",BigDecimal.valueOf(Tools.round(wuyeyongpin)));
			r_d2.put("jihuawai",BigDecimal.valueOf(Tools.round(jihuawai)));
			r_d2.put("meiriheji",BigDecimal.valueOf(Tools.round(total_meiriheji)));
			pageList.add(r_d2);
			
			r_d1.put("xingqi",gzr+"天");
			r_d1.put("shucai",BigDecimal.valueOf(Tools.aChuYib(shucai,gzr)));
			r_d1.put("liangshi",BigDecimal.valueOf(Tools.aChuYib(liangshi,gzr)));
			r_d1.put("zaliang",BigDecimal.valueOf(Tools.aChuYib(zaliang,gzr)));
			r_d1.put("mianshi",BigDecimal.valueOf(Tools.aChuYib(mianshi,gzr)));
			r_d1.put("danlei",BigDecimal.valueOf(Tools.aChuYib(danlei,gzr)));
			r_d1.put("fushi",BigDecimal.valueOf(Tools.aChuYib(fushi,gzr)));
			r_d1.put("banchengpin",BigDecimal.valueOf(Tools.aChuYib(banchengpin,gzr)));
			r_d1.put("tiaoliao",BigDecimal.valueOf(Tools.aChuYib(tiaoliao,gzr)));
			r_d1.put("ganhuo",BigDecimal.valueOf(Tools.aChuYib(ganhuo,gzr)));
			r_d1.put("shiyongyou",BigDecimal.valueOf(Tools.aChuYib(shiyongyou,gzr)));
			r_d1.put("qinlei",BigDecimal.valueOf(Tools.aChuYib(qinlei,gzr)));
			r_d1.put("chulei",BigDecimal.valueOf(Tools.aChuYib(chulei,gzr)));
			r_d1.put("shuichan",BigDecimal.valueOf(Tools.aChuYib(shuichan,gzr)));
			r_d1.put("yinliao",BigDecimal.valueOf(Tools.aChuYib(yinliao,gzr)));
			r_d1.put("shuiguo",BigDecimal.valueOf(Tools.aChuYib(shuiguo,gzr)));
			r_d1.put("gaodian",BigDecimal.valueOf(Tools.aChuYib(gaodian,gzr)));
			r_d1.put("dizhi",BigDecimal.valueOf(Tools.aChuYib(dizhi,gzr)));
			r_d1.put("tianjiaji",BigDecimal.valueOf(Tools.aChuYib(tianjiaji,gzr)));
			r_d1.put("qita",BigDecimal.valueOf(Tools.aChuYib(qita,gzr)));
			r_d1.put("wuyeyongpin",BigDecimal.valueOf(Tools.aChuYib(wuyeyongpin,gzr)));
			r_d1.put("jihuawai",BigDecimal.valueOf(Tools.aChuYib(jihuawai,gzr)));
			r_d1.put("meiriheji",BigDecimal.valueOf(Tools.aChuYib(total_meiriheji,gzr)));
			pageList.add(r_d1);
			
			reMap.put("rows", pageList);
			reMap.put("status", "success");
			reMap.put("message", "OK");
		} catch (Exception e) {
			e.printStackTrace();
			reMap.put("status", "error");
			reMap.put("message", e.getMessage());
		}
		return reMap;
	}
	
	//生成空行的合计行与日平均行
	public Map<String,Object> setNull_row(String riqi_title,String xingqi_title){
		Map<String,Object> m=new HashMap<>();
		m.put("riqi",riqi_title);m.put("xingqi",xingqi_title);m.put("shucai",null);m.put("liangshi",null);
		m.put("zaliang",null);m.put("mianshi",null);m.put("danlei",null);m.put("fushi",null);m.put("banchengpin",null);
		m.put("tiaoliao",null);m.put("ganhuo",null);m.put("shiyongyou",null);m.put("qinlei",null);m.put("chulei",null);
		m.put("shuichan",null);m.put("yinliao",null);m.put("shuiguo",null);m.put("gaodian",null);m.put("dizhi",null);
		m.put("tianjiaji",null);m.put("qita",null);m.put("wuyeyongpin",null);m.put("jihuawai",null);
		m.put("meiriheji",null);
		return m;
	}
	//处理有数据的行（每日合计采用全局变量进行辅助）
	public void setValue_row(Map<String,Object> src_m,Map<String,Object> value_m){
		String tz_zhonglei_name=(String)value_m.get("tz_zhonglei_name"); //取种类名称
		double total_tz_heji=Tools.round( ((BigDecimal)value_m.get("total_tz_heji")).doubleValue() ); //取该种类合计金额
		meiriheji+=total_tz_heji; //采用全局变量进行过渡辅助
		src_m.put("meiriheji",BigDecimal.valueOf(Tools.round(meiriheji)));
		if(tz_zhonglei_name.equals("蔬菜")){ //第1列：蔬菜
			src_m.put("shucai",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("粮食")){ //第2列：粮食
			src_m.put("liangshi",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("杂粮")){ //第3列：杂粮
			src_m.put("zaliang",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("面食")){ //第4列：面食
			src_m.put("mianshi",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("蛋类")){ //第5列：蛋类
			src_m.put("danlei",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("副食")){ //第6列：副食
			src_m.put("fushi",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("半成品")){ //第7列：半成品
			src_m.put("banchengpin",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("调料")){ //第8列：调料
			src_m.put("tiaoliao",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("干货")){ //第9列：干货
			src_m.put("ganhuo",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("食用油")){ //第10列：食用油
			src_m.put("shiyongyou",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("禽类")){ //第11列：禽类
			src_m.put("qinlei",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("畜类")){ //第12列：畜类
			src_m.put("chulei",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("水产")){ //第13列：水产
			src_m.put("shuichan",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("饮料")){ //第14列：饮料
			src_m.put("yinliao",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("水果")){ //第15列：水果
			src_m.put("shuiguo",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("糕点")){ //第16列：糕点
			src_m.put("gaodian",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("低值")){ //第17列：低值
			src_m.put("dizhi",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("添加剂")){ //第18列：添加剂
			src_m.put("tianjiaji",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("其他")){ //第19列：其他
			src_m.put("qita",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("物业用品")){ //第20列：物业用品
			src_m.put("wuyeyongpin",BigDecimal.valueOf(total_tz_heji));
		}
		if(tz_zhonglei_name.equals("计划外")){ //第21列：计划外
			src_m.put("jihuawai",BigDecimal.valueOf(total_tz_heji));
		}
	}
	
	//以下内容是市场调研数据与供应商供货价比对分析报表
	@Resource
	private B_ShChDYService b_ShChDYService;
	
	@RequestMapping(value ="/getBdxx_shchdy_gysh",method = RequestMethod.POST)
	@ResponseBody
	//（市场调研数据与供应商供货价格比对分析：按调研市场名称、按日期、（按项目名称）、按供应商（最多选3个）进行比对统计
	public Map<String,Object> getBdxx_shchdy_gysh(HttpServletRequest request,B_ShChDY b_ShChDY,String xm_name,String gyshs){
		Map<String,Object> reMap=new HashMap<>(); //定义返回值
		List<Map<String,Object>> pageList = new ArrayList<>(); //返回值中的页面集合项
		//注：取市场调研数据是带有分页的数据
		try {
			String start_time=Tools.TimestampToString(b_ShChDY.getDy_shijian()).substring(0,10); 
			b_ShChDY.setStart_time(start_time+" 00:00:00");
			b_ShChDY.setEnd_time(start_time+" 23:59:59");
			//取外循环：市场调研list
			Page<Map<String,Object>> shchdyList = (Page)b_ShChDYService.getB_ShChDYList(b_ShChDY);
			
			//取内循环：从台账中获取的供应商最近一次的送货价格（如需指定项目名称，sql中再加入项目名称条件）
			B_TZh b_TZh=new B_TZh();
			b_TZh.setTz_xiangmu_name(xm_name);
			List<Map<String,Object>> ghjg_tzh_gyshList= b_TZhService.getGhjg_tzh_gysh(null); //如需匹配项目名称，则传入b_TZh
			String gysh1="  ";String gysh2="  ";String gysh3="  "; //定义需要比对的3个供应商（默认2个空格，以避免空值比对上）
			if(gyshs!=null){ //
				String[] strArray=gyshs.split(",");
		        if(strArray.length==1){gysh1=strArray[0];}
		        if(strArray.length==2){gysh1=strArray[0];gysh2=strArray[1];}
		        if(strArray.length==3){gysh1=strArray[0];gysh2=strArray[1];gysh3=strArray[2];}
			}
			for(Map m_shchdy:shchdyList){ //外循环（市场调研价格）
				//分别获取外循环中每条记录中需要比对的5个参数（种类名称、食品物品名称、品牌、规格、单位）
				String dy_zhonglei_name=(String)m_shchdy.get("dy_zhonglei_name"); //种类名称
				String dy_shipin_name=(String)m_shchdy.get("dy_shipin_name"); //食（物）品名称
				String dy_pinpai=(String)m_shchdy.get("dy_pinpai"); //品牌
				String dy_guige=(String)m_shchdy.get("dy_guige"); //规格
				String dy_danwei=(String)m_shchdy.get("dy_danwei"); //单位
				double dy_jiage=((BigDecimal)m_shchdy.get("dy_jiage")).doubleValue(); //取调研价格
				//先预置空值
				m_shchdy.put("gysh_jiage1",null);
				m_shchdy.put("gysh_bili1",null);
				m_shchdy.put("gysh_jiage2",null);
				m_shchdy.put("gysh_bili2",null);
				m_shchdy.put("gysh_jiage3",null);
				m_shchdy.put("gysh_bili3",null);
				System.out.println("外循环："+dy_zhonglei_name+","+dy_shipin_name+","+dy_pinpai+","+
				                   dy_guige+","+dy_danwei+","+dy_jiage);
				for(Map m_gysh:ghjg_tzh_gyshList){ //内循环（从台账中获取的供应商最近一次的送货价格）
					//分别获取内循环中每条记录中需要比对的5个参数（种类名称、食品物品名称、品牌、规格、单位）
					String tz_zhonglei_name=(String)m_gysh.get("tz_zhonglei_name"); //种类名称
					String tz_shipin_name=(String)m_gysh.get("tz_shipin_name"); //食（物）品名称
					String tz_pinpai=(String)m_gysh.get("tz_pinpai"); //品牌
					String tz_guige=(String)m_gysh.get("tz_guige"); //规格
					String tz_danwei=(String)m_gysh.get("tz_danwei"); //单位
					String tz_gyshang_name=(String)m_gysh.get("tz_gyshang_name"); //供应商名称
					//System.out.println("供应商："+tz_gyshang_name+"内循环："+tz_zhonglei_name+","+tz_shipin_name+","+
					                   //tz_pinpai+","+tz_guige+","+tz_danwei);
					if(dy_zhonglei_name.equals(tz_zhonglei_name)&&dy_shipin_name.equals(tz_shipin_name)&&
					   //dy_pinpai.equals(tz_pinpai)&&dy_guige.equals(tz_guige)&&
					   dy_danwei.equals(tz_danwei)){
						double tz_danjia=((BigDecimal)m_gysh.get("tz_danjia")).doubleValue(); //取台账供应商供货价格
						System.out.println("比对上供应商："+tz_gyshang_name+"内循环："+tz_zhonglei_name+","+tz_shipin_name+","+
				                   tz_pinpai+","+tz_guige+","+tz_danwei+","+tz_danjia);
						if(tz_gyshang_name.equals(gysh1)){ //当前记录比对上第1个供应商
							//m_shchdy.put("gysh_jiage1",BigDecimal.valueOf(tz_danjia));
							m_shchdy.put("gysh_jiage1",tz_gyshang_name+":"+tz_danjia);
							double gysh_bili1=Tools.round((tz_danjia-dy_jiage)/dy_jiage*100);
							m_shchdy.put("gysh_bili1",BigDecimal.valueOf(gysh_bili1));
						}
						if(tz_gyshang_name.equals(gysh2)){ //当前记录比对上第2个供应商
							//m_shchdy.put("gysh_jiage2",BigDecimal.valueOf(tz_danjia));
							m_shchdy.put("gysh_jiage2",tz_gyshang_name+":"+tz_danjia);
							double gysh_bili2=Tools.round((tz_danjia-dy_jiage)/dy_jiage*100);
							m_shchdy.put("gysh_bili2",BigDecimal.valueOf(gysh_bili2));
						}
						if(tz_gyshang_name.equals(gysh3)){ //当前记录比对上第3个供应商
							//m_shchdy.put("gysh_jiage3",BigDecimal.valueOf(tz_danjia));
							m_shchdy.put("gysh_jiage3",tz_gyshang_name+":"+tz_danjia);
							double gysh_bili3=Tools.round((tz_danjia-dy_jiage)/dy_jiage*100);
							m_shchdy.put("gysh_bili3",BigDecimal.valueOf(gysh_bili3));
						}
					}
				} //内循环结束
				pageList.add(m_shchdy);
			} //外循环结束
			
			reMap.put("rows", pageList);
			reMap.put("status", "success");
			reMap.put("message", "OK");
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			reMap.put("status", "error");
			reMap.put("message", e.getMessage());
		}
		return reMap;
	}
	
	//以下内容是门店（项目）月数据汇总分析报表
	@Resource
	private B_HT_MService b_HT_MService;
	
	@RequestMapping(value ="/getHzxx_mendianguanli",method = RequestMethod.POST)
	@ResponseBody
	//（门店月数据汇总分析：按项目名称、按年份）门店管理，合同月数据每年的汇总统计表
	public Map<String,Object> getHzxx_mendianguanli(HttpServletRequest request,B_HT_M b_HT_M,String year){
		Map<String,Object> reMap=new HashMap<>(); //定义返回值
		List<Map<String,Object>> pageList = new ArrayList<>(); //返回值中的页面集合项
		try {
			b_HT_M.setStart_time(year+"-01-01 00:00:00"); //"2024-01-01 00:00:00"
			b_HT_M.setEnd_time(year+"-12-31 23:59:59"); //"2024-12-31 23:59:59"
			Page<Map<String,Object>> rList=(Page)b_HT_MService.getB_HT_MList(b_HT_M);
			//System.out.println(rList);
			
			//一：构造外循环（12个月，从1月循环到12月）
			for(int i=1;i<=12;i++){
				Map<String,Object> rowMap=new HashMap<>(); //行map（每一个月是一行）
				String ym=year;
				String ymdhms="";
				if(i<10){
					ym=ym+"-0"+i;
					
				}else{
					ym=ym+"-"+i;
				}
				ymdhms=ym+"-01 00:00:00";
				System.out.println("此时外循环年月=="+ym);
				System.out.println("此时外循环年月日时分秒=="+ymdhms);
				if(rList.size()==0){ //本年度没有数据，则全都补充空行数据
					System.out.println("需要赋一行空值，此时外循环日期=="+ym);
					rowMap=setNull_row_mendian(ym); //门店管理生成一条月空数据
					pageList.add(rowMap);
					if(i==12){ //如果是最后一个月
						Map<String,Object> rowMap_d2=setNull_row_mendian("合计"); //倒数第二行（合计行）
						pageList.add(rowMap_d2);
						Map<String,Object> rowMap_d1=setNull_row_mendian("合并汇总"); //倒数第一行（合并汇总行）
						pageList.add(rowMap_d1);
						
						reMap.put("rows", pageList);
						reMap.put("status", "success");
						reMap.put("message", "OK");
						return reMap; //无数据的情况下，并执行完按月循环，生成当月天数的空数据后直接返回
					}
				}else{ //本年度有数据
					//1：先生成一条空数据
					rowMap=setNull_row_mendian(ym); //门店管理生成一条月空数据
					pageList.add(rowMap); //先将空数据加入到返回值中，如在内循环中月份比对成功，则再替换掉相应的值
					int j=0; //测试用
					for(Map m:rList){ //柳林2024年有1条11月数据
						j++; //测试用
						System.out.println("内循环第"+j+"条数据库记录");
						String m_shijian=Tools.TimestampToString((Timestamp)m.get("m_shijian"));
						if(m_shijian.equals(ymdhms)){
							System.out.println("外循环i=="+i);
							System.out.println("内循环比对相等的日期是=="+m_shijian);
							//2：如果日期比对正确，则将数据填充到前面1：生成的空数据中
							setValue_row_mendian(rowMap,m);
							rowMap.put("m_shijian",ym); //将m_shijian改为显示年月
						}
					} //内for循环结束
				}
			} //外循环结束
			
			//二：处理该年份每月数据集合pageList，补充最后两行（倒数第二行是按列合计，倒数第一行是合并汇总）
			double m_hetongfei=0;double m_wuyefei=0;double m_canfei=0;double m_jihuawai_canbu=0;
			double m_jihuawai_hetongwai=0;double m_shuifei=0;double m_gongzi=0;double m_shebao=0;double m_shangbao=0;
			double m_gongjijin=0;double m_jiaotongfei=0;double m_shicai=0;double m_haocai=0;double m_wuyezhichu=0;
			double m_jihuawai_suiqing=0;double m_jihuawai_weixiu=0;double m_jihuawai_yanqing=0;double m_jihuawai_jiaxu=0;
			double m_shichangjingyingfei=0;double m_fupin_832fupin=0;double m_fupin_shangwuju=0;double m_fupin_dingxiang=0;
			double m_lirun=0;
			//1：先算每列的合计
			for(int i=0;i<pageList.size();i++){
				Map<String,Object> m=pageList.get(i);
				m_hetongfei+=m.get("m_hetongfei")==null ? 0 : ((BigDecimal)m.get("m_hetongfei")).doubleValue();
				m_wuyefei+=m.get("m_wuyefei")==null ? 0 : ((BigDecimal)m.get("m_wuyefei")).doubleValue();
				m_canfei+=m.get("m_canfei")==null ? 0 : ((BigDecimal)m.get("m_canfei")).doubleValue();
				m_jihuawai_canbu+=m.get("m_jihuawai_canbu")==null ? 0 : ((BigDecimal)m.get("m_jihuawai_canbu")).doubleValue();
				m_jihuawai_hetongwai+=m.get("m_jihuawai_hetongwai")==null ? 0 : ((BigDecimal)m.get("m_jihuawai_hetongwai")).doubleValue();
				m_shuifei+=m.get("m_shuifei")==null ? 0 : ((BigDecimal)m.get("m_shuifei")).doubleValue();
				m_gongzi+=m.get("m_gongzi")==null ? 0 : ((BigDecimal)m.get("m_gongzi")).doubleValue();
				m_shebao+=m.get("m_shebao")==null ? 0 : ((BigDecimal)m.get("m_shebao")).doubleValue();
				m_shangbao+=m.get("m_shangbao")==null ? 0 : ((BigDecimal)m.get("m_shangbao")).doubleValue();
				m_gongjijin+=m.get("m_gongjijin")==null ? 0 : ((BigDecimal)m.get("m_gongjijin")).doubleValue();
				m_jiaotongfei+=m.get("m_jiaotongfei")==null ? 0 : ((BigDecimal)m.get("m_jiaotongfei")).doubleValue();
				m_shicai+=m.get("m_shicai")==null ? 0 : ((BigDecimal)m.get("m_shicai")).doubleValue();
				m_haocai+=m.get("m_haocai")==null ? 0 : ((BigDecimal)m.get("m_haocai")).doubleValue();
				m_wuyezhichu+=m.get("m_wuyezhichu")==null ? 0 : ((BigDecimal)m.get("m_wuyezhichu")).doubleValue();
				m_jihuawai_suiqing+=m.get("m_jihuawai_suiqing")==null ? 0 : ((BigDecimal)m.get("m_jihuawai_suiqing")).doubleValue();
				m_jihuawai_weixiu+=m.get("m_jihuawai_weixiu")==null ? 0 : ((BigDecimal)m.get("m_jihuawai_weixiu")).doubleValue();
				m_jihuawai_yanqing+=m.get("m_jihuawai_yanqing")==null ? 0 : ((BigDecimal)m.get("m_jihuawai_yanqing")).doubleValue();
				m_jihuawai_jiaxu+=m.get("m_jihuawai_jiaxu")==null ? 0 : ((BigDecimal)m.get("m_jihuawai_jiaxu")).doubleValue();
				m_shichangjingyingfei+=m.get("m_shichangjingyingfei")==null ? 0 : ((BigDecimal)m.get("m_shichangjingyingfei")).doubleValue();
				m_fupin_832fupin+=m.get("m_fupin_832fupin")==null ? 0 : ((BigDecimal)m.get("m_fupin_832fupin")).doubleValue();
				m_fupin_shangwuju+=m.get("m_fupin_shangwuju")==null ? 0 : ((BigDecimal)m.get("m_fupin_shangwuju")).doubleValue();
				m_fupin_dingxiang+=m.get("m_fupin_dingxiang")==null ? 0 : ((BigDecimal)m.get("m_fupin_dingxiang")).doubleValue();
				m_lirun+=m.get("m_lirun")==null ? 0 : ((BigDecimal)m.get("m_lirun")).doubleValue();
			}
			//2：再生成最后两行
			Map<String,Object> r_d2=setNull_row_mendian("合计"); //倒数第二行（合计行）
			Map<String,Object> r_d1=setNull_row_mendian("合并汇总"); //倒数第一行（合并汇总行）
			r_d2.put("m_hetongfei",BigDecimal.valueOf(Tools.round(m_hetongfei)));
			r_d2.put("m_wuyefei",BigDecimal.valueOf(Tools.round(m_wuyefei)));
			r_d2.put("m_canfei",BigDecimal.valueOf(Tools.round(m_canfei)));
			r_d2.put("m_jihuawai_canbu",BigDecimal.valueOf(Tools.round(m_jihuawai_canbu)));
			r_d2.put("m_jihuawai_hetongwai",BigDecimal.valueOf(Tools.round(m_jihuawai_hetongwai)));
			r_d2.put("m_shuifei",BigDecimal.valueOf(Tools.round(m_shuifei)));
			r_d2.put("m_gongzi",BigDecimal.valueOf(Tools.round(m_gongzi)));
			r_d2.put("m_shebao",BigDecimal.valueOf(Tools.round(m_shebao)));
			r_d2.put("m_shangbao",BigDecimal.valueOf(Tools.round(m_shangbao)));
			r_d2.put("m_gongjijin",BigDecimal.valueOf(Tools.round(m_gongjijin)));
			r_d2.put("m_jiaotongfei",BigDecimal.valueOf(Tools.round(m_jiaotongfei)));
			r_d2.put("m_shicai",BigDecimal.valueOf(Tools.round(m_shicai)));
			r_d2.put("m_haocai",BigDecimal.valueOf(Tools.round(m_haocai)));
			r_d2.put("m_wuyezhichu",BigDecimal.valueOf(Tools.round(m_wuyezhichu)));
			r_d2.put("m_jihuawai_suiqing",BigDecimal.valueOf(Tools.round(m_jihuawai_suiqing)));
			r_d2.put("m_jihuawai_weixiu",BigDecimal.valueOf(Tools.round(m_jihuawai_weixiu)));
			r_d2.put("m_jihuawai_yanqing",BigDecimal.valueOf(Tools.round(m_jihuawai_yanqing)));
			r_d2.put("m_jihuawai_jiaxu",BigDecimal.valueOf(Tools.round(m_jihuawai_jiaxu)));
			r_d2.put("m_shichangjingyingfei",BigDecimal.valueOf(Tools.round(m_shichangjingyingfei)));
			r_d2.put("m_fupin_832fupin",BigDecimal.valueOf(Tools.round(m_fupin_832fupin)));
			r_d2.put("m_fupin_shangwuju",BigDecimal.valueOf(Tools.round(m_fupin_shangwuju)));
			r_d2.put("m_fupin_dingxiang",BigDecimal.valueOf(Tools.round(m_fupin_dingxiang)));
			r_d2.put("m_lirun",BigDecimal.valueOf(Tools.round(m_lirun)));
			pageList.add(r_d2);
			
			//r_d1.put("m_hetongfei",BigDecimal.valueOf(Tools.round(m_hetongfei)));
			String str_m_hetongfei="合同额:"+Tools.round(m_hetongfei)+"元";
			r_d1.put("m_hetongfei",str_m_hetongfei);
			
			//r_d1.put("m_wuyefei",BigDecimal.valueOf(Tools.round(m_wuyefei)));
			//r_d1.put("m_canfei",BigDecimal.valueOf(Tools.round(m_canfei)));
			//r_d1.put("m_jihuawai_canbu",BigDecimal.valueOf(Tools.round(m_jihuawai_canbu)));
			//r_d1.put("m_jihuawai_hetongwai",BigDecimal.valueOf(Tools.round(m_jihuawai_hetongwai)));
			String str_m_wuyefei="收入:"+Tools.round(m_wuyefei+m_canfei+m_jihuawai_canbu+m_jihuawai_hetongwai)+"元";
			r_d1.put("m_wuyefei",str_m_wuyefei);
			//上面4项是：收入
			
			//r_d1.put("m_shuifei",BigDecimal.valueOf(Tools.round(m_shuifei)));
			//r_d1.put("m_gongzi",BigDecimal.valueOf(Tools.round(m_gongzi)));
			//r_d1.put("m_shebao",BigDecimal.valueOf(Tools.round(m_shebao)));
			//r_d1.put("m_shangbao",BigDecimal.valueOf(Tools.round(m_shangbao)));
			//r_d1.put("m_gongjijin",BigDecimal.valueOf(Tools.round(m_gongjijin)));
			//r_d1.put("m_jiaotongfei",BigDecimal.valueOf(Tools.round(m_jiaotongfei)));
			//r_d1.put("m_shicai",BigDecimal.valueOf(Tools.round(m_shicai)));
			//r_d1.put("m_haocai",BigDecimal.valueOf(Tools.round(m_haocai)));
			//r_d1.put("m_wuyezhichu",BigDecimal.valueOf(Tools.round(m_wuyezhichu)));
			//r_d1.put("m_jihuawai_suiqing",BigDecimal.valueOf(Tools.round(m_jihuawai_suiqing)));
			//r_d1.put("m_jihuawai_weixiu",BigDecimal.valueOf(Tools.round(m_jihuawai_weixiu)));
			//r_d1.put("m_jihuawai_yanqing",BigDecimal.valueOf(Tools.round(m_jihuawai_yanqing)));
			//r_d1.put("m_jihuawai_jiaxu",BigDecimal.valueOf(Tools.round(m_jihuawai_jiaxu)));
			//r_d1.put("m_shichangjingyingfei",BigDecimal.valueOf(Tools.round(m_shichangjingyingfei)));
			String str_m_shuifei="费用支出:"+Tools.round(m_shuifei+m_gongzi+m_shebao+m_shangbao+m_gongjijin+
					                                    m_jiaotongfei+m_shicai+m_haocai+m_wuyezhichu+m_jihuawai_suiqing+
					                                    m_jihuawai_weixiu+m_jihuawai_yanqing+m_jihuawai_jiaxu+
					                                    m_shichangjingyingfei)+"元";
			r_d1.put("m_shuifei",str_m_shuifei);
			//上面14项是：费用支出
			
			//r_d1.put("m_fupin_832fupin",BigDecimal.valueOf(Tools.round(m_fupin_832fupin)));
			//r_d1.put("m_fupin_shangwuju",BigDecimal.valueOf(Tools.round(m_fupin_shangwuju)));
			//r_d1.put("m_fupin_dingxiang",BigDecimal.valueOf(Tools.round(m_fupin_dingxiang)));
			String str_m_fupin_832fupin="扶贫支出:"+Tools.round(m_fupin_832fupin+m_fupin_shangwuju+m_fupin_dingxiang)+"元";
			r_d1.put("m_fupin_832fupin",str_m_fupin_832fupin);
			//上面3项是：扶贫支出
			
			//r_d1.put("m_lirun",BigDecimal.valueOf(Tools.round(m_lirun)));
			String str_m_lirun="利润:"+Tools.round(m_lirun)+"元";
			r_d1.put("m_lirun",str_m_lirun);
			//上面1项是：利润
			
			pageList.add(r_d1);
			
			reMap.put("rows", pageList);
			reMap.put("status", "success");
			reMap.put("message", "OK");
		} catch (Exception e) {
			e.printStackTrace();
			reMap.put("status", "error");
			reMap.put("message", e.getMessage());
		}
		return reMap;
	}
	//生成门店管理的空行数据
	public Map<String,Object> setNull_row_mendian(String ym_title){
		Map<String,Object> m=new HashMap<>();
		m.put("m_shijian",ym_title);m.put("m_hetongfei",null);m.put("m_wuyefei",null);
		if(ym_title.equals("合并汇总")){m.put("m_wuyefei","收入:0元");};
		m.put("m_canfei",null);
		m.put("m_jihuawai_canbu",null);m.put("m_jihuawai_hetongwai",null);m.put("m_shuifei",null);
		if(ym_title.equals("合并汇总")){m.put("m_shuifei","费用支出:0元");};
		m.put("m_gongzi",null);m.put("m_shebao",null);m.put("m_shangbao",null);m.put("m_gongjijin",null);
		m.put("m_jiaotongfei",null);m.put("m_shicai",null);m.put("m_haocai",null);m.put("m_wuyezhichu",null);
		m.put("m_jihuawai_suiqing",null);m.put("m_jihuawai_weixiu",null);m.put("m_jihuawai_yanqing",null);
		m.put("m_jihuawai_jiaxu",null);m.put("m_shichangjingyingfei",null);m.put("m_fupin_832fupin",null);
		if(ym_title.equals("合并汇总")){m.put("m_fupin_832fupin","扶贫支出:0元");};
		m.put("m_fupin_shangwuju",null);m.put("m_fupin_dingxiang",null);m.put("m_lirun",null);
		return m;
	}
	//处理有数据的行（将value_m中的值赋值给src_m）
	public void setValue_row_mendian(Map<String,Object> src_m,Map<String,Object> value_m){
		src_m.put("m_hetongfei",(BigDecimal)value_m.get("m_hetongfei"));
		src_m.put("m_wuyefei",(BigDecimal)value_m.get("m_wuyefei"));
		src_m.put("m_canfei",(BigDecimal)value_m.get("m_canfei"));
		src_m.put("m_jihuawai_canbu",(BigDecimal)value_m.get("m_jihuawai_canbu"));
		src_m.put("m_jihuawai_hetongwai",(BigDecimal)value_m.get("m_jihuawai_hetongwai"));
		src_m.put("m_shuifei",(BigDecimal)value_m.get("m_shuifei"));
		src_m.put("m_gongzi",(BigDecimal)value_m.get("m_gongzi"));
		src_m.put("m_shebao",(BigDecimal)value_m.get("m_shebao"));
		src_m.put("m_shangbao",(BigDecimal)value_m.get("m_shangbao"));
		src_m.put("m_gongjijin",(BigDecimal)value_m.get("m_gongjijin"));
		src_m.put("m_jiaotongfei",(BigDecimal)value_m.get("m_jiaotongfei"));
		src_m.put("m_shicai",(BigDecimal)value_m.get("m_shicai"));
		src_m.put("m_haocai",(BigDecimal)value_m.get("m_haocai"));
		src_m.put("m_wuyezhichu",(BigDecimal)value_m.get("m_wuyezhichu"));
		src_m.put("m_jihuawai_suiqing",(BigDecimal)value_m.get("m_jihuawai_suiqing"));
		src_m.put("m_jihuawai_weixiu",(BigDecimal)value_m.get("m_jihuawai_weixiu"));
		src_m.put("m_jihuawai_yanqing",(BigDecimal)value_m.get("m_jihuawai_yanqing"));
		src_m.put("m_jihuawai_jiaxu",(BigDecimal)value_m.get("m_jihuawai_jiaxu"));
		src_m.put("m_shichangjingyingfei",(BigDecimal)value_m.get("m_shichangjingyingfei"));
		src_m.put("m_fupin_832fupin",(BigDecimal)value_m.get("m_fupin_832fupin"));
		src_m.put("m_fupin_shangwuju",(BigDecimal)value_m.get("m_fupin_shangwuju"));
		src_m.put("m_fupin_dingxiang",(BigDecimal)value_m.get("m_fupin_dingxiang"));
		src_m.put("m_lirun",(BigDecimal)value_m.get("m_lirun"));
	}
	
	//以下内容是门店费用占比报表
	@RequestMapping(value ="/getFyzhb",method = RequestMethod.POST)
	@ResponseBody
	//（门店费用占比分析：按项目名称、按年月）门店管理，合同月数据中各项费用占比统计表
	public Map<String,Object> getFyzhb(HttpServletRequest request,B_HT_M b_HT_M){
		Map<String,Object> reMap=new HashMap<>(); //定义返回值
		List<Map<String,Object>> pageList = new ArrayList<>(); //返回值中的页面集合项
		Map<String,Object> m01=new HashMap<>(); //对应m_wuyefei
		Map<String,Object> m02=new HashMap<>(); //对应m_canfei
		Map<String,Object> m03=new HashMap<>(); //对应m_jihuawai_canbu
		Map<String,Object> m04=new HashMap<>(); //对应m_jihuawai_hetongwai
		Map<String,Object> m03_04=new HashMap<>(); //计划外收入（合同外与餐补）
		Map<String,Object> m05=new HashMap<>(); //对应m_shuifei
		Map<String,Object> m06=new HashMap<>(); //对应m_gongzi
		Map<String,Object> m07=new HashMap<>(); //对应m_shebao
		Map<String,Object> m08=new HashMap<>(); //对应m_shangbao
		Map<String,Object> m07_08=new HashMap<>(); //对应保险（社保与商保）
		Map<String,Object> m09=new HashMap<>(); //对应m_gongjijin
		Map<String,Object> m10=new HashMap<>(); //对应m_jiaotongfei
		Map<String,Object> m11=new HashMap<>(); //对应m_shicai
		Map<String,Object> m12=new HashMap<>(); //对应m_haocai
		Map<String,Object> m13=new HashMap<>(); //对应m_wuyezhichu
		Map<String,Object> m14=new HashMap<>(); //对应m_jihuawai_suiqing
		Map<String,Object> m15=new HashMap<>(); //对应m_jihuawai_weixiu
		Map<String,Object> m16=new HashMap<>(); //对应m_jihuawai_yanqing
		Map<String,Object> m17=new HashMap<>(); //对应m_jihuawai_jiaxu
		Map<String,Object> m14_17=new HashMap<>(); //对应计划外支出（碎请、维修、宴请、甲需）
		Map<String,Object> m18=new HashMap<>(); //对应m_shichangjingyingfei
		Map<String,Object> m19=new HashMap<>(); //对应m_fupin_832fupin
		Map<String,Object> m20=new HashMap<>(); //对应m_fupin_shangwuju
		Map<String,Object> m21=new HashMap<>(); //对应m_fupin_dingxiang
		Map<String,Object> m19_21=new HashMap<>(); //对应扶贫（832扶贫、商务局、定向）
		try {
			Page<Map<String,Object>> rList=(Page)b_HT_MService.getB_HT_MList(b_HT_M);
			//System.out.println(rList);
			//常规字段值
			double m_hetongfei=0; //需要单独保存，并且需要参与比例计算
			double m_wuyefei=0;double m_canfei=0;double m_jihuawai_canbu=0;double m_jihuawai_hetongwai=0;double m_shuifei=0;
			double m_gongzi=0;double m_shebao=0;double m_shangbao=0;double m_gongjijin=0;double m_jiaotongfei=0;
			double m_shicai=0;double m_haocai=0;double m_wuyezhichu=0;double m_jihuawai_suiqing=0;double m_jihuawai_weixiu=0;
			double m_jihuawai_yanqing=0;double m_jihuawai_jiaxu=0;double m_shichangjingyingfei=0;double m_fupin_832fupin=0;
			double m_fupin_shangwuju=0;double m_fupin_dingxiang=0;
			String m_xiangmu_name=b_HT_M.getM_xiangmu_name();
			String m_shijian=Tools.TimestampToString(b_HT_M.getM_shijian()).substring(0,7);
			if(rList.size()==0){
				//没有查到相应的数据，结果集赋空值
				m01.put("m_xiangmu_name",m_xiangmu_name);m01.put("m_shijian",m_shijian);m01.put("m_hetongfei",null);
				m01.put("feiyong_name","物业费");m01.put("feiyong_jinE",null);m01.put("bili",null);
				m02.put("m_xiangmu_name",m_xiangmu_name);m02.put("m_shijian",m_shijian);m02.put("m_hetongfei",null);
				m02.put("feiyong_name","餐费");m02.put("feiyong_jinE",null);m02.put("bili",null);
				m03.put("m_xiangmu_name",m_xiangmu_name);m03.put("m_shijian",m_shijian);m03.put("m_hetongfei",null);
				m03.put("feiyong_name","（计划外收入）餐补");m03.put("feiyong_jinE",null);m03.put("bili",null);
				m04.put("m_xiangmu_name",m_xiangmu_name);m04.put("m_shijian",m_shijian);m04.put("m_hetongfei",null);
				m04.put("feiyong_name","（计划外收入）合同外");m04.put("feiyong_jinE",null);m04.put("bili",null);
				m05.put("m_xiangmu_name",m_xiangmu_name);m05.put("m_shijian",m_shijian);m05.put("m_hetongfei",null);
				m05.put("feiyong_name","税费");m05.put("feiyong_jinE",null);m05.put("bili",null);
				m06.put("m_xiangmu_name",m_xiangmu_name);m06.put("m_shijian",m_shijian);m06.put("m_hetongfei",null);
				m06.put("feiyong_name","工资");m06.put("feiyong_jinE",null);m06.put("bili",null);
				m07.put("m_xiangmu_name",m_xiangmu_name);m07.put("m_shijian",m_shijian);m07.put("m_hetongfei",null);
				m07.put("feiyong_name","（保险）社保");m07.put("feiyong_jinE",null);m07.put("bili",null);
				m08.put("m_xiangmu_name",m_xiangmu_name);m08.put("m_shijian",m_shijian);m08.put("m_hetongfei",null);
				m08.put("feiyong_name","（保险）商保");m08.put("feiyong_jinE",null);m08.put("bili",null);
				m09.put("m_xiangmu_name",m_xiangmu_name);m09.put("m_shijian",m_shijian);m09.put("m_hetongfei",null);
				m09.put("feiyong_name","公积金");m09.put("feiyong_jinE",null);m09.put("bili",null);
				m10.put("m_xiangmu_name",m_xiangmu_name);m10.put("m_shijian",m_shijian);m10.put("m_hetongfei",null);
				m10.put("feiyong_name","交通费");m10.put("feiyong_jinE",null);m10.put("bili",null);
				m11.put("m_xiangmu_name",m_xiangmu_name);m11.put("m_shijian",m_shijian);m11.put("m_hetongfei",null);
				m11.put("feiyong_name","食材");m11.put("feiyong_jinE",null);m11.put("bili",null);
				m12.put("m_xiangmu_name",m_xiangmu_name);m12.put("m_shijian",m_shijian);m12.put("m_hetongfei",null);
				m12.put("feiyong_name","耗材");m12.put("feiyong_jinE",null);m12.put("bili",null);
				m13.put("m_xiangmu_name",m_xiangmu_name);m13.put("m_shijian",m_shijian);m13.put("m_hetongfei",null);
				m13.put("feiyong_name","物业支出");m13.put("feiyong_jinE",null);m13.put("bili",null);
				m14.put("m_xiangmu_name",m_xiangmu_name);m14.put("m_shijian",m_shijian);m14.put("m_hetongfei",null);
				m14.put("feiyong_name","（计划外支出）碎请");m14.put("feiyong_jinE",null);m14.put("bili",null);
				m15.put("m_xiangmu_name",m_xiangmu_name);m15.put("m_shijian",m_shijian);m15.put("m_hetongfei",null);
				m15.put("feiyong_name","（计划外支出）维修");m15.put("feiyong_jinE",null);m15.put("bili",null);
				m16.put("m_xiangmu_name",m_xiangmu_name);m16.put("m_shijian",m_shijian);m16.put("m_hetongfei",null);
				m16.put("feiyong_name","（计划外支出）宴请");m16.put("feiyong_jinE",null);m16.put("bili",null);
				m17.put("m_xiangmu_name",m_xiangmu_name);m17.put("m_shijian",m_shijian);m17.put("m_hetongfei",null);
				m17.put("feiyong_name","（计划外支出）甲需");m17.put("feiyong_jinE",null);m17.put("bili",null);
				m18.put("m_xiangmu_name",m_xiangmu_name);m18.put("m_shijian",m_shijian);m18.put("m_hetongfei",null);
				m18.put("feiyong_name","市场经营费");m18.put("feiyong_jinE",null);m18.put("bili",null);				
				m19.put("m_xiangmu_name",m_xiangmu_name);m19.put("m_shijian",m_shijian);m19.put("m_hetongfei",null);
				m19.put("feiyong_name","（扶贫）832扶贫");m19.put("feiyong_jinE",null);m19.put("bili",null);
				m20.put("m_xiangmu_name",m_xiangmu_name);m20.put("m_shijian",m_shijian);m20.put("m_hetongfei",null);
				m20.put("feiyong_name","（扶贫）商务局");m20.put("feiyong_jinE",null);m20.put("bili",null);
				m21.put("m_xiangmu_name",m_xiangmu_name);m21.put("m_shijian",m_shijian);m21.put("m_hetongfei",null);
				m21.put("feiyong_name","（扶贫）定向");m21.put("feiyong_jinE",null);m21.put("bili",null);
				
				m03_04.put("m_xiangmu_name",m_xiangmu_name);m03_04.put("m_shijian",m_shijian);m03_04.put("m_hetongfei",null);
				m03_04.put("feiyong_name","计划外收入（合同外与餐补）");m03_04.put("feiyong_jinE",null);m03_04.put("bili",null);
				m07_08.put("m_xiangmu_name",m_xiangmu_name);m07_08.put("m_shijian",m_shijian);m07_08.put("m_hetongfei",null);
				m07_08.put("feiyong_name","保险（社保与商保）");m07_08.put("feiyong_jinE",null);m07_08.put("bili",null);
				m14_17.put("m_xiangmu_name",m_xiangmu_name);m14_17.put("m_shijian",m_shijian);m14_17.put("m_hetongfei",null);
				m14_17.put("feiyong_name","计划外支出（碎请,维修,宴请,甲需）");m14_17.put("feiyong_jinE",null);m14_17.put("bili",null);
				m19_21.put("m_xiangmu_name",m_xiangmu_name);m19_21.put("m_shijian",m_shijian);m19_21.put("m_hetongfei",null);
				m19_21.put("feiyong_name","扶贫（832扶贫,商务局,定向）");m19_21.put("feiyong_jinE",null);m19_21.put("bili",null);
				
				//将空值项加到返回值中
				pageList.add(m01);pageList.add(m02);pageList.add(m03);pageList.add(m04);pageList.add(m05);pageList.add(m06);
				pageList.add(m07);pageList.add(m08);pageList.add(m09);pageList.add(m10);pageList.add(m11);pageList.add(m12);
				pageList.add(m13);pageList.add(m14);pageList.add(m15);pageList.add(m16);pageList.add(m17);pageList.add(m18);
				pageList.add(m19);pageList.add(m20);pageList.add(m21);
				pageList.add(m03_04);pageList.add(m07_08);pageList.add(m14_17);pageList.add(m19_21);
			}else{
				for(Map m:rList){ //柳林2024年有1条10月数据
					//根据条件，查询条件最多只有1条
					m_hetongfei=m.get("m_hetongfei")==null ? 0 : ((BigDecimal)m.get("m_hetongfei")).doubleValue();
					m_wuyefei=m.get("m_wuyefei")==null ? 0 : ((BigDecimal)m.get("m_wuyefei")).doubleValue();
					m_canfei=m.get("m_canfei")==null ? 0 : ((BigDecimal)m.get("m_canfei")).doubleValue();
					m_jihuawai_canbu=m.get("m_jihuawai_canbu")==null ? 0 : ((BigDecimal)m.get("m_jihuawai_canbu")).doubleValue();
					m_jihuawai_hetongwai=m.get("m_jihuawai_hetongwai")==null ? 0 : ((BigDecimal)m.get("m_jihuawai_hetongwai")).doubleValue();
					m_shuifei=m.get("m_shuifei")==null ? 0 : ((BigDecimal)m.get("m_shuifei")).doubleValue();
					m_gongzi=m.get("m_gongzi")==null ? 0 : ((BigDecimal)m.get("m_gongzi")).doubleValue();
					m_shebao=m.get("m_shebao")==null ? 0 : ((BigDecimal)m.get("m_shebao")).doubleValue();
					m_shangbao=m.get("m_shangbao")==null ? 0 : ((BigDecimal)m.get("m_shangbao")).doubleValue();
					m_gongjijin=m.get("m_gongjijin")==null ? 0 : ((BigDecimal)m.get("m_gongjijin")).doubleValue();
					m_jiaotongfei=m.get("m_jiaotongfei")==null ? 0 : ((BigDecimal)m.get("m_jiaotongfei")).doubleValue();
					m_shicai=m.get("m_shicai")==null ? 0 : ((BigDecimal)m.get("m_shicai")).doubleValue();
					m_haocai=m.get("m_haocai")==null ? 0 : ((BigDecimal)m.get("m_haocai")).doubleValue();
					m_wuyezhichu=m.get("m_wuyezhichu")==null ? 0 : ((BigDecimal)m.get("m_wuyezhichu")).doubleValue();
					m_jihuawai_suiqing=m.get("m_jihuawai_suiqing")==null ? 0 : ((BigDecimal)m.get("m_jihuawai_suiqing")).doubleValue();
					m_jihuawai_weixiu=m.get("m_jihuawai_weixiu")==null ? 0 : ((BigDecimal)m.get("m_jihuawai_weixiu")).doubleValue();
					m_jihuawai_yanqing=m.get("m_jihuawai_yanqing")==null ? 0 : ((BigDecimal)m.get("m_jihuawai_yanqing")).doubleValue();
					m_jihuawai_jiaxu=m.get("m_jihuawai_jiaxu")==null ? 0 : ((BigDecimal)m.get("m_jihuawai_jiaxu")).doubleValue();
					m_shichangjingyingfei=m.get("m_shichangjingyingfei")==null ? 0 : ((BigDecimal)m.get("m_shichangjingyingfei")).doubleValue();
					m_fupin_832fupin=m.get("m_fupin_832fupin")==null ? 0 : ((BigDecimal)m.get("m_fupin_832fupin")).doubleValue();
					m_fupin_shangwuju=m.get("m_fupin_shangwuju")==null ? 0 : ((BigDecimal)m.get("m_fupin_shangwuju")).doubleValue();
					m_fupin_dingxiang=m.get("m_fupin_dingxiang")==null ? 0 : ((BigDecimal)m.get("m_fupin_dingxiang")).doubleValue();
				} //循环结束
				
				//根据字段值计算比例（保留4位小数），并形成返回值
				//常规字段比例定义
				double m_wuyefei_bili=0;double m_canfei_bili=0;double m_jihuawai_canbu_bili=0;double m_jihuawai_hetongwai_bili=0;
				double m_shuifei_bili=0;double m_gongzi_bili=0;double m_shebao_bili=0;double m_shangbao_bili=0;
				double m_gongjijin_bili=0;double m_jiaotongfei_bili=0;double m_shicai_bili=0;double m_haocai_bili=0;
				double m_wuyezhichu_bili=0;double m_jihuawai_suiqing_bili=0;double m_jihuawai_weixiu_bili=0;
				double m_jihuawai_yanqing_bili=0;double m_jihuawai_jiaxu_bili=0;double m_shichangjingyingfei_bili=0;
				double m_fupin_832fupin_bili=0;double m_fupin_shangwuju_bili=0;double m_fupin_dingxiang_bili=0;
				//补充某些项的合并字段比例
				double baoxian_bili=0; //保险（社保与商保）
				double jihuawai_shouru_bili=0; //计划外收入（合同外与餐补）
				double jihuawai_zhichu_bili=0; //计划外支出（碎请、维修、宴请、甲需）
				double fupin_bili=0; //扶贫（832扶贫、商务局、定向）
				
				//计算比例
				m_wuyefei_bili=Tools.getBili(m_wuyefei,m_hetongfei,4);
				m_canfei_bili=Tools.getBili(m_canfei,m_hetongfei,4);
				m_jihuawai_canbu_bili=Tools.getBili(m_jihuawai_canbu,m_hetongfei,4);
				m_jihuawai_hetongwai_bili=Tools.getBili(m_jihuawai_hetongwai,m_hetongfei,4);
				jihuawai_shouru_bili=m_jihuawai_canbu_bili+m_jihuawai_hetongwai_bili; //属于合并项
				m_shuifei_bili=Tools.getBili(m_shuifei,m_hetongfei,4);
				m_gongzi_bili=Tools.getBili(m_gongzi,m_hetongfei,4);
				m_shebao_bili=Tools.getBili(m_shebao,m_hetongfei,4);
				m_shangbao_bili=Tools.getBili(m_shangbao,m_hetongfei,4);
				baoxian_bili=m_shebao_bili+m_shangbao_bili; //属于合并项
				m_gongjijin_bili=Tools.getBili(m_gongjijin,m_hetongfei,4);
				m_jiaotongfei_bili=Tools.getBili(m_jiaotongfei,m_hetongfei,4);
				m_shicai_bili=Tools.getBili(m_shicai,m_hetongfei,4);
				m_haocai_bili=Tools.getBili(m_haocai,m_hetongfei,4);
				m_wuyezhichu_bili=Tools.getBili(m_wuyezhichu,m_hetongfei,4);
				m_jihuawai_suiqing_bili=Tools.getBili(m_jihuawai_suiqing,m_hetongfei,4);
				m_jihuawai_weixiu_bili=Tools.getBili(m_jihuawai_weixiu,m_hetongfei,4);
				m_jihuawai_yanqing_bili=Tools.getBili(m_jihuawai_yanqing,m_hetongfei,4);
				m_jihuawai_jiaxu_bili=Tools.getBili(m_jihuawai_jiaxu,m_hetongfei,4);
				jihuawai_zhichu_bili=m_jihuawai_suiqing_bili+m_jihuawai_weixiu_bili+m_jihuawai_yanqing_bili+m_jihuawai_jiaxu_bili; //属于合并项
				m_shichangjingyingfei_bili=Tools.getBili(m_shichangjingyingfei,m_hetongfei,4);
				m_fupin_832fupin_bili=Tools.getBili(m_fupin_832fupin,m_hetongfei,4);
				m_fupin_shangwuju_bili=Tools.getBili(m_fupin_shangwuju,m_hetongfei,4);
				m_fupin_dingxiang_bili=Tools.getBili(m_fupin_dingxiang,m_hetongfei,4);
				fupin_bili=m_fupin_832fupin_bili+m_fupin_shangwuju_bili+m_fupin_dingxiang_bili;
				
				//构造页面行元素
				m01.put("m_xiangmu_name",m_xiangmu_name);m01.put("m_shijian",m_shijian);
				m01.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m01.put("feiyong_name","物业费");
				m01.put("feiyong_jinE",BigDecimal.valueOf(m_wuyefei));
				m01.put("bili",BigDecimal.valueOf(m_wuyefei_bili));
				
				m02.put("m_xiangmu_name",m_xiangmu_name);m02.put("m_shijian",m_shijian);
				m02.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m02.put("feiyong_name","餐费");
				m02.put("feiyong_jinE",BigDecimal.valueOf(m_canfei));
				m02.put("bili",BigDecimal.valueOf(m_canfei_bili));
								
				m03.put("m_xiangmu_name",m_xiangmu_name);m03.put("m_shijian",m_shijian);
				m03.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m03.put("feiyong_name","（计划外收入）餐补");
				m03.put("feiyong_jinE",BigDecimal.valueOf(m_jihuawai_canbu));
				m03.put("bili",BigDecimal.valueOf(m_jihuawai_canbu_bili));
				
				m04.put("m_xiangmu_name",m_xiangmu_name);m04.put("m_shijian",m_shijian);
				m04.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m04.put("feiyong_name","（计划外收入）合同外");
				m04.put("feiyong_jinE",BigDecimal.valueOf(m_jihuawai_hetongwai));
				m04.put("bili",BigDecimal.valueOf(m_jihuawai_hetongwai_bili));
				
				m05.put("m_xiangmu_name",m_xiangmu_name);m05.put("m_shijian",m_shijian);
				m05.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m05.put("feiyong_name","税费");
				m05.put("feiyong_jinE",BigDecimal.valueOf(m_shuifei));
				m05.put("bili",BigDecimal.valueOf(m_shuifei_bili));
				
				m06.put("m_xiangmu_name",m_xiangmu_name);m06.put("m_shijian",m_shijian);
				m06.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m06.put("feiyong_name","工资");
				m06.put("feiyong_jinE",BigDecimal.valueOf(m_gongzi));
				m06.put("bili",BigDecimal.valueOf(m_gongzi_bili));
				
				m07.put("m_xiangmu_name",m_xiangmu_name);m07.put("m_shijian",m_shijian);
				m07.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m07.put("feiyong_name","（保险）社保");
				m07.put("feiyong_jinE",BigDecimal.valueOf(m_shebao));
				m07.put("bili",BigDecimal.valueOf(m_shebao_bili));
				
				m08.put("m_xiangmu_name",m_xiangmu_name);m08.put("m_shijian",m_shijian);
				m08.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m08.put("feiyong_name","（保险）商保");
				m08.put("feiyong_jinE",BigDecimal.valueOf(m_shangbao));
				m08.put("bili",BigDecimal.valueOf(m_shangbao_bili));
				
				m09.put("m_xiangmu_name",m_xiangmu_name);m09.put("m_shijian",m_shijian);
				m09.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m09.put("feiyong_name","公积金");
				m09.put("feiyong_jinE",BigDecimal.valueOf(m_gongjijin));
				m09.put("bili",BigDecimal.valueOf(m_gongjijin_bili));
				
				m10.put("m_xiangmu_name",m_xiangmu_name);m10.put("m_shijian",m_shijian);
				m10.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m10.put("feiyong_name","交通费");
				m10.put("feiyong_jinE",BigDecimal.valueOf(m_jiaotongfei));
				m10.put("bili",BigDecimal.valueOf(m_jiaotongfei_bili));
				
				m11.put("m_xiangmu_name",m_xiangmu_name);m11.put("m_shijian",m_shijian);
				m11.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m11.put("feiyong_name","食材");
				m11.put("feiyong_jinE",BigDecimal.valueOf(m_shicai));
				m11.put("bili",BigDecimal.valueOf(m_shicai_bili));
				
				m12.put("m_xiangmu_name",m_xiangmu_name);m12.put("m_shijian",m_shijian);
				m12.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m12.put("feiyong_name","耗材");
				m12.put("feiyong_jinE",BigDecimal.valueOf(m_haocai));
				m12.put("bili",BigDecimal.valueOf(m_haocai_bili));
				
				m13.put("m_xiangmu_name",m_xiangmu_name);m13.put("m_shijian",m_shijian);
				m13.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m13.put("feiyong_name","物业支出");
				m13.put("feiyong_jinE",BigDecimal.valueOf(m_wuyezhichu));
				m13.put("bili",BigDecimal.valueOf(m_wuyezhichu_bili));
				
				m14.put("m_xiangmu_name",m_xiangmu_name);m14.put("m_shijian",m_shijian);
				m14.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m14.put("feiyong_name","（计划外支出）碎请");
				m14.put("feiyong_jinE",BigDecimal.valueOf(m_jihuawai_suiqing));
				m14.put("bili",BigDecimal.valueOf(m_jihuawai_suiqing_bili));
				
				m15.put("m_xiangmu_name",m_xiangmu_name);m15.put("m_shijian",m_shijian);
				m15.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m15.put("feiyong_name","（计划外支出）维修");
				m15.put("feiyong_jinE",BigDecimal.valueOf(m_jihuawai_weixiu));
				m15.put("bili",BigDecimal.valueOf(m_jihuawai_weixiu_bili));
				
				m16.put("m_xiangmu_name",m_xiangmu_name);m16.put("m_shijian",m_shijian);
				m16.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m16.put("feiyong_name","（计划外支出）宴请");
				m16.put("feiyong_jinE",BigDecimal.valueOf(m_jihuawai_yanqing));
				m16.put("bili",BigDecimal.valueOf(m_jihuawai_yanqing_bili));
				
				m17.put("m_xiangmu_name",m_xiangmu_name);m17.put("m_shijian",m_shijian);
				m17.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m17.put("feiyong_name","（计划外支出）甲需");
				m17.put("feiyong_jinE",BigDecimal.valueOf(m_jihuawai_jiaxu));
				m17.put("bili",BigDecimal.valueOf(m_jihuawai_jiaxu_bili));
				
				m18.put("m_xiangmu_name",m_xiangmu_name);m18.put("m_shijian",m_shijian);
				m18.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m18.put("feiyong_name","市场经营费");
				m18.put("feiyong_jinE",BigDecimal.valueOf(m_shichangjingyingfei));
				m18.put("bili",BigDecimal.valueOf(m_shichangjingyingfei_bili));				
				
				m19.put("m_xiangmu_name",m_xiangmu_name);m19.put("m_shijian",m_shijian);
				m19.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m19.put("feiyong_name","（扶贫）832扶贫");
				m19.put("feiyong_jinE",BigDecimal.valueOf(m_fupin_832fupin));
				m19.put("bili",BigDecimal.valueOf(m_fupin_832fupin_bili));
				
				m20.put("m_xiangmu_name",m_xiangmu_name);m20.put("m_shijian",m_shijian);
				m20.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m20.put("feiyong_name","（扶贫）商务局");
				m20.put("feiyong_jinE",BigDecimal.valueOf(m_fupin_shangwuju));
				m20.put("bili",BigDecimal.valueOf(m_fupin_shangwuju_bili));
				
				m21.put("m_xiangmu_name",m_xiangmu_name);m21.put("m_shijian",m_shijian);
				m21.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m21.put("feiyong_name","（扶贫）定向");
				m21.put("feiyong_jinE",BigDecimal.valueOf(m_fupin_dingxiang));
				m21.put("bili",BigDecimal.valueOf(m_fupin_dingxiang_bili));
				
				m03_04.put("m_xiangmu_name",m_xiangmu_name);m03_04.put("m_shijian",m_shijian);
				m03_04.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m03_04.put("feiyong_name","计划外收入（合同外与餐补）");
				m03_04.put("feiyong_jinE",BigDecimal.valueOf(m_jihuawai_hetongwai+m_jihuawai_canbu));
				m03_04.put("bili",BigDecimal.valueOf(jihuawai_shouru_bili));
				
				m07_08.put("m_xiangmu_name",m_xiangmu_name);m07_08.put("m_shijian",m_shijian);
				m07_08.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m07_08.put("feiyong_name","保险（社保与商保）");
				m07_08.put("feiyong_jinE",BigDecimal.valueOf(m_shebao+m_shangbao));
				m07_08.put("bili",BigDecimal.valueOf(baoxian_bili));
				
				m14_17.put("m_xiangmu_name",m_xiangmu_name);m14_17.put("m_shijian",m_shijian);
				m14_17.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m14_17.put("feiyong_name","计划外支出（碎请,维修,宴请,甲需）");
				m14_17.put("feiyong_jinE",BigDecimal.valueOf(m_jihuawai_suiqing+m_jihuawai_weixiu+m_jihuawai_yanqing+m_jihuawai_jiaxu));
				m14_17.put("bili",BigDecimal.valueOf(jihuawai_zhichu_bili));
				
				m19_21.put("m_xiangmu_name",m_xiangmu_name);m19_21.put("m_shijian",m_shijian);
				m19_21.put("m_hetongfei",BigDecimal.valueOf(m_hetongfei));m19_21.put("feiyong_name","扶贫（832扶贫,商务局,定向）");
				m19_21.put("feiyong_jinE",BigDecimal.valueOf(m_fupin_832fupin+m_fupin_shangwuju+m_fupin_dingxiang));
				m19_21.put("bili",BigDecimal.valueOf(fupin_bili));
				
				//将行元素项加到返回值中
				pageList.add(m01);pageList.add(m02);pageList.add(m03);pageList.add(m04);pageList.add(m05);pageList.add(m06);
				pageList.add(m07);pageList.add(m08);pageList.add(m09);pageList.add(m10);pageList.add(m11);pageList.add(m12);
				pageList.add(m13);pageList.add(m14);pageList.add(m15);pageList.add(m16);pageList.add(m17);pageList.add(m18);
				pageList.add(m19);pageList.add(m20);pageList.add(m21);
				pageList.add(m03_04);pageList.add(m07_08);pageList.add(m14_17);pageList.add(m19_21);
			}
			
			reMap.put("rows", pageList);
			reMap.put("status", "success");
			reMap.put("message", "OK");
		} catch (Exception e) {
			e.printStackTrace();
			reMap.put("status", "error");
			reMap.put("message", e.getMessage());
		}
		return reMap;
	}
	
	//以下内容是门店（项目）食（物）品用量统计报表
	@RequestMapping(value ="/getYltj",method = RequestMethod.POST)
	@ResponseBody
	//（门店食品物品用量统计分析：按项目名称、按大类别、按食品物品名称、按开始时间、按截止时间）食（物）品用量统计报表
	public Map<String,Object> getYltj(HttpServletRequest request,B_TZh b_TZh){
		Map<String,Object> reMap=new HashMap<>(); //定义返回值
		List<Map<String,Object>> pageList = new ArrayList<>(); //返回值中的页面集合项
		try{
			List<Map<String,Object>> rList=b_TZhService.getYltj(b_TZh); 
			System.out.println(rList);//这种list方式的查询如果没有结果的话，会是[null]的方式返回
			
			//由于汇总的原因，日期（riqi字段）不是一个准确的字段，因此需要将riqi字段处理为 start_time -- end_time 的方式
			for(Map m:rList){ //柳林11月数据有197条统计记录
				String riqi=b_TZh.getStart_time()+" 至 "+b_TZh.getEnd_time();
				m.put("riqi",riqi);
			}
			reMap.put("rows", rList);
			reMap.put("status", "success");
			reMap.put("message", "OK");
		}catch (Exception e) {
			e.printStackTrace();
			reMap.put("status", "error");
			reMap.put("message", e.getMessage());
		}
		return reMap;
	}
	
	//以下内容是门店入口率报表（暂未完成）
	@Resource
	private A_ZDService a_ZDService; 

	@RequestMapping(value ="/getRukoulv",method = RequestMethod.POST)
	@ResponseBody
	//（门店入口率月统计：按月份、按项目名称、按工作日）按月统计
	//入口率报表目前暂未完成
	public Map<String,Object> getRukoulv(HttpServletRequest request,String mendian,String start_time,Integer gongzuori){
		Map<String,Object> reMap=new HashMap<>(); //定义返回值
		List<Map<String,Object>> pageList = new ArrayList<>(); //原接口中的页面集合项（保留这个变量名，以便减少代码修改）
		List<Map<String,Object>> rstList = new ArrayList<>(); //最终的页面返回值集合项
		int gzr=gongzuori.intValue(); //取工作日数
		try {
			//一：构造外循环集合（项目名称集合）
			A_ZD a_ZD=new A_ZD();
			a_ZD.setZidian_name("项目名称");
			List<Map<String,Object>> xmList=a_ZDService.getA_ZDList(a_ZD); //不带分页
			for(Map xm:xmList){ //大外循环，遍历所有项目名称
				String mch=(String)xm.get("zidian_value");
				//针对每个项目取当前月份的台账各个种类的汇总信息（就是getHzxx_meiri_leibie接口的逻辑）
				//以下代码基本上取自getHzxx_meiri_leibie接口的逻辑
				start_time=start_time.substring(0,10); //"2024-11-01";
				String end_time=Tools.lastDayOfMonth(start_time);
				B_TZh b_TZh=new B_TZh();
				b_TZh.setTz_xiangmu_name(mch);
				b_TZh.setStart_time(start_time+" 00:00:00");
				b_TZh.setEnd_time(end_time);
				List<Map<String,Object>> rList=b_TZhService.getHzxx_meiri_leibie(b_TZh); 
				//System.out.println(rList);//这种list方式的查询如果没有结果的话，会是[null]的方式返回
				//一：构造外循环（以11月为例，从1号循环到30号）
				int daysInMonth=Tools.daysInMonth(start_time);
				String yyyy=start_time.substring(0,4);
				String MM=start_time.substring(5,7);
				for(int i=1;i<=daysInMonth;i++){
					meiriheji=0; //按日期累计求和（外循环每次开始时都需要初始化一下，相当于一行一个合计数据）
					Map<String,Object> rowMap=new HashMap<>(); //行map（每一天是一行）
					String riqi="";
					if(i<=9){
						riqi=yyyy+"-"+MM+"-0"+i;
					}else{
						riqi=yyyy+"-"+MM+"-"+i;
					}
					String xingqi=Tools.dayOfWeek(riqi);
					if(rList.size()>0){
						//1：先生成一条空数据
						rowMap=setNull_row(riqi,xingqi); //每天生成一条空数据
						int j=0;
						for(Map m:rList){ //柳林11月数据有197条统计记录
							j++;
							System.out.println("第"+j+"条数据库记录");
							String rq=(String)m.get("riqi");
							if(rq.equals(riqi)){
								//System.out.println("外循环i=="+i);
								//System.out.println("内循环比对相等的日期是=="+rq);
								//2：如果日期比对正确，则将数据填充到前面1：生成的空数据中
								setValue_row(rowMap,m);
							}
							//3：循环到最后一行，加入到集合
							if(j==rList.size()){
								pageList.add(rowMap);
							}
							//System.out.println("****=="+j);
						} //内for循环结束
					}
				} //外循环结束
				
				//二：处理数据集合pageList（按列求和），最后获取需要的数据：本月所有采购成本合计 － 其他合计 － 物业用品合计 － 计划外合计
				double shucai=0;double liangshi=0;double zaliang=0;double mianshi=0;double danlei=0;double fushi=0;
				double banchengpin=0;double tiaoliao=0;double ganhuo=0;double shiyongyou=0;double qinlei=0;double chulei=0;
				double shuichan=0;double yinliao=0;double shuiguo=0;double gaodian=0;double dizhi=0;double tianjiaji=0;
				double qita=0;double wuyeyongpin=0;double jihuawai=0;double total_meiriheji=0;
				//1：先算每列的合计
				for(int i=0;i<pageList.size();i++){
					Map<String,Object> m=pageList.get(i);
					shucai+=m.get("shucai")==null ? 0 : ((BigDecimal)m.get("shucai")).doubleValue();
					liangshi+=m.get("liangshi")==null ? 0 : ((BigDecimal)m.get("liangshi")).doubleValue();
					zaliang+=m.get("zaliang")==null ? 0 : ((BigDecimal)m.get("zaliang")).doubleValue();
					mianshi+=m.get("mianshi")==null ? 0 : ((BigDecimal)m.get("mianshi")).doubleValue();
					danlei+=m.get("danlei")==null ? 0 : ((BigDecimal)m.get("danlei")).doubleValue();
					fushi+=m.get("fushi")==null ? 0 : ((BigDecimal)m.get("fushi")).doubleValue();
					banchengpin+=m.get("banchengpin")==null ? 0 : ((BigDecimal)m.get("banchengpin")).doubleValue();
					tiaoliao+=m.get("tiaoliao")==null ? 0 : ((BigDecimal)m.get("tiaoliao")).doubleValue();
					ganhuo+=m.get("ganhuo")==null ? 0 : ((BigDecimal)m.get("ganhuo")).doubleValue();
					shiyongyou+=m.get("shiyongyou")==null ? 0 : ((BigDecimal)m.get("shiyongyou")).doubleValue();
					qinlei+=m.get("qinlei")==null ? 0 : ((BigDecimal)m.get("qinlei")).doubleValue();
					chulei+=m.get("chulei")==null ? 0 : ((BigDecimal)m.get("chulei")).doubleValue();
					shuichan+=m.get("shuichan")==null ? 0 : ((BigDecimal)m.get("shuichan")).doubleValue();
					yinliao+=m.get("yinliao")==null ? 0 : ((BigDecimal)m.get("yinliao")).doubleValue();
					shuiguo+=m.get("shuiguo")==null ? 0 : ((BigDecimal)m.get("shuiguo")).doubleValue();
					gaodian+=m.get("gaodian")==null ? 0 : ((BigDecimal)m.get("gaodian")).doubleValue();
					dizhi+=m.get("dizhi")==null ? 0 : ((BigDecimal)m.get("dizhi")).doubleValue();
					tianjiaji+=m.get("tianjiaji")==null ? 0 : ((BigDecimal)m.get("tianjiaji")).doubleValue();
					qita+=m.get("qita")==null ? 0 : ((BigDecimal)m.get("qita")).doubleValue();
					wuyeyongpin+=m.get("wuyeyongpin")==null ? 0 : ((BigDecimal)m.get("wuyeyongpin")).doubleValue();
					jihuawai+=m.get("jihuawai")==null ? 0 : ((BigDecimal)m.get("jihuawai")).doubleValue();
					total_meiriheji+=m.get("meiriheji")==null ? 0 : ((BigDecimal)m.get("meiriheji")).doubleValue();
				}
				//2：取合同用餐人数、当月餐标、实际用餐人数
				//3：取上月的盘点总价
				//5：取本月的盘点总价
				//6：计算实际采购金额（本月所有采购成本合计－其他合计－物业用品合计－计划外合计＋上月盘点总价－本月盘点总价）
				//double shiJiCaiGou_jinE=

				
				
				
			} //大外循环结束
			
			
			
			reMap.put("rows", rstList);
			reMap.put("status", "success");
			reMap.put("message", "OK");
		} catch (Exception e) {
			e.printStackTrace();
			reMap.put("status", "error");
			reMap.put("message", e.getMessage());
		}
		return reMap;
	}
	
}
